package prolog.fluents;

import prolog.terms.Const;
import prolog.terms.Prog;
import prolog.terms.Sink;
import prolog.terms.Term;

/**
  Builds  Fluents from Java
  Streams
*/
 class StringSink extends Sink {
  protected StringBuffer buffer;
  
  def StringSink(p:Prog):Unit{
//    super(p);
    this.buffer=new StringBuffer();
  }
  
  def putElement(Term t):Int {
    buffer.append(t.toUnquoted());
    return 1;
  }
  
  def stop() {
    buffer=null;
  }
  
  def collect():Term {new Const(buffer.toString()); }
}